﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class PhieuThuDAL
    {
        ConnectionData conn;

        public DataTable PhieuThu_Load()
        {
            conn = new ConnectionData();
            return conn.GetData("PHIEUTHU_LOAD");
        }

        public int PhieuThu_Insert(PhieuThuDTO PT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaCTLH";
            value[0] = PT_DTO.MaCTLH;
            name[1] = "SoTienThu";
            value[1] = PT_DTO.SoTienThu;
            name[2] = "NgayThu";
            value[2] = PT_DTO.NgayThu;

            return conn.UpdateData("PHIEUTHU_INSERT", name, value, Nparameter);
        }

        public int PhieuThu_Update(PhieuThuDTO PT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaPhieuThu";
            value[0] = PT_DTO.MaPhieuThu;
            name[1] = "MaCTLT";
            value[1] = PT_DTO.MaCTLH;
            name[2] = "SoTienThu";
            value[2] = PT_DTO.NgayThu;
            name[3] = "NgaySinh";
            value[3] = PT_DTO.NgayThu;

            return conn.UpdateData("PHIEUTHU_UPDATE", name, value, Nparameter);
        }

        public int PhieuThu_Delete(PhieuThuDTO PT_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaPhieuThu";
            value[0] = PT_DTO.MaPhieuThu;

            return conn.UpdateData("PHIEUTHU_DELETE", name, value, Nparameter);
        }
    }
}
